<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

  <link rel="stylesheet" href="./css/商品跳转2.css">
   
    <script src="./js/jquery.min.js"></script>
    <link rel="stylesheet" href="./js/商品跳转2.js">



<style>
  
</style>
    
    
</head>
<body>

<span class="tou">平板电视产品销量排行</span>

<ul class="box">
    <!-- <li>
        <img src="../瀑布流/1.jpg">
        <div class="didi">
            <span>乐视TV(letv)超3 X55 55英寸只能LED液晶 超级电视 4K超清电视</span>
            <span>￥3266</span>
            <span>⭐⭐⭐⭐⭐</span>
            <span>报价(9)</span>
            <span>评论(667)</span>
        </div>
    </li>  -->
</ul>



    <script>  

         var  url = decodeURI(location.href)
    
         url=url.split('?')[1]

        console.log(url);
       var box=document.querySelector('.box')
        var brandtitleid=localStorage.getItem('brandtitleId')
        console.log(brandtitleid)
        let xhr2=new XMLHttpRequest()
        xhr2.open('get',`http://chst.vip:1234/api/getbrandproductlist?brandtitleid=${brandtitleid}&pagesize=${4}`,true,)
        xhr2.onload=function(){

            if(xhr2.status===200){
                var res2=JSON.parse(xhr2.responseText)
                //  console.log(res2.result)
            var lis2=''
            var n=1
            let regExp = /^<[^<]+\s+src="([^''""]*)"/;


            res2.result.forEach(function(so,ind){
            let tu = res2.result[ind].productImg.match(regExp)[1];
            // console.log(tu)

                lis2+=`

               <li productid='${so.productId}'>
                    <img src="${tu}">
                    <div class="didi">
                        <span class="hea">${so.productName}</span>
                        <span>${so.productPrice}</span>
                        <span>⭐⭐⭐⭐⭐</span>
                        <span>${so.productQuote}</span>
                        <span>${so.productCom}</span>
                    </div>
                </li> 
                     `
            })
            box.innerHTML=lis2


            $(function(){
            $('li').click(function(ev){
            var e=ev||event
          

            var target=e.target||e.srcElement
          
          
            if(target.nodeName==="IMG"){
                localStorage.setItem("productid",target.parentNode.getAttribute('productid'))
              location.href="./商品跳转详情页.html"

            }
          

        })

        })
            }
           
        }
   
        xhr2.send()
       
     


    </script>
</body>
</html>